home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / More Classes / Advanced Dialogs / ZExtraDialogItems.h < prev   
Encoding:
C/C++ Source or Header  |  1997-06-11  |  5.6 KB  |  218 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp        -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZExtraDialogItems.h    -- some other kinds of dialog item objects
  9. *
  10. *
  11. *            © 1997, Graham Cox
  12. *
  13. *
  14. *
  15. *************************************************************************************************/
  16.  
  17. #pragma once
  18.  
  19. #ifndef __ZEXTRADIALOGITEMS__
  20. #define    __ZEXTRADIALOGITEMS__
  21.  
  22.  
  23. #include    "ZAdvancedDialog.h"
  24.  
  25. // types of lines:
  26.  
  27. typedef enum
  28. {
  29.     plainLine,            
  30.     patternLine,
  31.     raised3DLine,
  32.     etched3DLine
  33. }
  34. LineType;
  35.  
  36. // line class- used to draw straight lines in dialogs
  37.  
  38. class    ZLineDialogItem    : public ZDialogItem
  39. {
  40. protected:
  41.     LineType    itsType;
  42.     short        patIndex;
  43.  
  44. public:
  45.     ZLineDialogItem( ZDialog* aDialog, short item );
  46.     
  47.     virtual void    DrawItem();
  48.     virtual void    InitItem( const long param1, const long param2 );
  49. };
  50.  
  51.  
  52. #define        kLineItemMagicString    'LINE'
  53.  
  54. // icon hiliting style
  55.  
  56. typedef enum
  57. {
  58.     iconHiliteBoldBorder = 1,        // draw bold box around icon
  59.     iconHiliteDarken = 2,            // "select" the icon
  60.     iconHiliteInvertTitle = 4,        // invert the title string
  61.     iconHiliteInvertCell = 8,        // invert the entire cell (but not icon)
  62.     iconHiliteUseHColour = 16,        // use hilite colour for inversion
  63.     iconDefaultHilite = iconHiliteDarken + iconHiliteInvertTitle
  64. }
  65. IconHilite;
  66.  
  67. // n.b. modes can be combined together if desired. Default is darken + invert title
  68.  
  69.  
  70. // icon listbox class- used to create listboxes with icons, based on 'ICLB' resources
  71.  
  72. class    ZIconListBox    : public ZListDialogItem
  73. {
  74. protected:
  75.     Boolean        showTitles;        // show icon titles?
  76.     Boolean        smallIcons;        // TRUE if we use 16 x 16 rather than 32 x 32
  77.     IconHilite    iHilite;        // how to hilite the icons
  78.     
  79.     
  80. public:
  81.     ZIconListBox( ZDialog* aDialog, short item );
  82.     ~ZIconListBox();
  83.  
  84.     virtual void        InitItem( const long param1, const long param2 );
  85.     
  86.     inline    IconHilite    GetHiliteStyle() { return iHilite; };
  87.     inline    Boolean        ShowTitles() { return showTitles; };
  88.     
  89. protected:
  90.     virtual void        MakeMacList( const short listTemplateID = 0 );
  91.     virtual void        InstallIconLDEF();
  92.     virtual void        AddIconCells( const short templateID );
  93.     virtual void        DisposeIconCells();
  94. };
  95.  
  96. // template for icon list box resource ('ICLB')
  97.  
  98. #if PRAGMA_ALIGN_SUPPORTED
  99. #pragma options align=mac68k
  100. #endif
  101.  
  102. typedef struct
  103. {
  104.     short        resID;                // res ID of icon
  105.     short        iconType;            // type of icon (ICON, cicn or ICN#)
  106.     short        nameIndex;            // index into STR# for title
  107. }
  108. IconRec;
  109.  
  110. typedef struct
  111. {
  112.     short        hiliteStyle;        // hiliting method to use (same as above)
  113.     short        hSpacing;            // spacing between horizontal icons
  114.     short        vSpacing;            // spacing between vertical icons
  115.     short        titleListResID;        // res id of STR# with titles
  116.     Boolean        addTitles : 1;        // show titles with icons
  117.     Boolean        useResName : 1;        // use icon's res name for title
  118.     Boolean        useSmallIcons : 1;    // use small icons instead of large
  119.     Boolean        unused : 5;            // reserved
  120.     short        numIcons;            // number of icons in following array
  121.     IconRec        icons[1];            // variable length array of icon defs
  122. }
  123. IconListBox, *IconListBoxPtr, **IconListBoxHdl;
  124.  
  125. #define        kIconListTemplateResType    'ICLB'
  126. #define        kIconListboxMagicString        'ICLB'
  127.  
  128. // icon types in template
  129.  
  130. #define        kBasicIcon        0        // uses 'ICON' resource
  131. #define        kColourIcon        1        // uses 'cicn' resource
  132. #define        kFamilyIcon        2        // uses 'ICN#', 'icl8', etc. resources
  133.  
  134.  
  135. #if PRAGMA_ALIGN_SUPPORTED
  136. #pragma options align=reset
  137. #endif
  138.  
  139. // icon types
  140.  
  141. typedef enum
  142. {
  143.     IconPlain,
  144.     IconColour,
  145.     IconFamily,
  146.     IconSuite,
  147.     IconIndexed
  148. }
  149. IconType;
  150.  
  151. // internal structure kept in list cells:
  152.  
  153. typedef struct
  154. {
  155.     IconType    iType;                // icon's type (colour, family, etc)
  156.     Handle        theIcon;            // handle to the icon if loaded
  157.     short        iconID;                // resource ID of the icon
  158.     long        userData;            // reserved for your own use if needed
  159.     Str31        title;                // icon's title string, if any
  160. }
  161. IconInfo;
  162.  
  163. // class for scrolling textbox dialog item:
  164.  
  165. class    ZScrollingTextBox : public ZDialogItem
  166. {
  167. protected:
  168.     TEHandle        te;                    // textEdit record
  169.     ControlHandle    scroll;                // scrollbar
  170.     Boolean            editable;            // TRUE if editable text
  171.     short            resID;                // res ID of TEXT/styl resource
  172.     short            lineHeight;            // height of a line
  173.     short            pageHeight;            // height of a "page"
  174.  
  175. public:
  176.     ZScrollingTextBox( ZDialog* aDialog, short item );
  177.     ~ZScrollingTextBox();
  178.  
  179. // overrides:    
  180.     virtual void        InitItem( const long param1, const long param2 );
  181.     virtual void        DrawItem();
  182.     virtual void        ClickItem( const Point where, const short modifiers );
  183.     virtual void        AdjustCursor( const Point where, const short modifiers );
  184.     virtual void        Activate( const Boolean isActive );
  185.     virtual void        Type( const char theKey );
  186.     virtual void        Idle();
  187.     virtual void        BecomeHandler( Boolean isBecoming );
  188.     
  189.     virtual void        DoCut();
  190.     virtual void        DoCopy();
  191.     virtual void        DoPaste();
  192.     virtual void        DoClear();
  193.     virtual void        DoSelectAll();
  194.     virtual Boolean        CanPasteType();
  195.     virtual void        UpdateMenus();
  196.  
  197. // original methods:    
  198.     virtual void        SetText( Handle textH, Handle styleH = NULL );
  199.     virtual void        GetText( Handle textH, Handle styleH = NULL );
  200.     virtual void        Scroll( short delta );
  201.     virtual void        DoScroll( short partCode );
  202.     
  203.     virtual void        CalScroll();
  204.     
  205.     inline    TEHandle    GetTextHandle() { return te; };
  206.     
  207. protected:
  208.     virtual void        MakeMacTEAndScroll();
  209.     virtual void        PreloadText();
  210.     virtual Boolean        PtInScrollbar( const Point mouse );
  211. };
  212.  
  213. // these items provide a vertically scrolling textbox, containing the text from a 'TEXT'
  214. // (and 'styl' if present) resource. The magic string is $$TEXT,id,e where <id> is the res ID
  215. // of the TEXT/styl resources, and <e> is 0 (or missing) for read-only, 1 for editable. If
  216. // editable, the keyboard focus will be applied as normal.
  217.  
  218. #endif